home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / controls / setfont.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-05-16  |  5.6 KB  |  175 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "You, Too, Can Be an Optometrist"
  4.    ClientHeight    =   2715
  5.    ClientLeft      =   1185
  6.    ClientTop       =   1770
  7.    ClientWidth     =   7770
  8.    Height          =   3120
  9.    Left            =   1125
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   2715
  12.    ScaleWidth      =   7770
  13.    Top             =   1425
  14.    Width           =   7890
  15.    Begin CommandButton cmdCount 
  16.       Caption         =   "Control Count"
  17.       Height          =   495
  18.       Left            =   6000
  19.       TabIndex        =   3
  20.       Top             =   240
  21.       Width           =   1455
  22.    End
  23.    Begin CommandButton cmdShrink 
  24.       Caption         =   "Shrink"
  25.       Enabled         =   0   'False
  26.       Height          =   495
  27.       Left            =   240
  28.       TabIndex        =   2
  29.       Top             =   1080
  30.       Width           =   1215
  31.    End
  32.    Begin CommandButton cmdEnd 
  33.       Caption         =   "End"
  34.       Height          =   495
  35.       Left            =   6240
  36.       TabIndex        =   1
  37.       Top             =   1080
  38.       Width           =   1215
  39.    End
  40.    Begin CommandButton cmdEnlarge 
  41.       Caption         =   "Enlarge"
  42.       Height          =   495
  43.       Left            =   240
  44.       TabIndex        =   0
  45.       Top             =   240
  46.       Width           =   1215
  47.    End
  48.    Begin Label lblFive 
  49.       BorderStyle     =   1  'Fixed Single
  50.       Height          =   255
  51.       Left            =   3360
  52.       TabIndex        =   8
  53.       Top             =   2280
  54.       Width           =   500
  55.    End
  56.    Begin Label lblFour 
  57.       BorderStyle     =   1  'Fixed Single
  58.       Height          =   255
  59.       Left            =   3360
  60.       TabIndex        =   7
  61.       Top             =   1680
  62.       Width           =   500
  63.    End
  64.    Begin Label lblThree 
  65.       BorderStyle     =   1  'Fixed Single
  66.       Height          =   255
  67.       Left            =   3360
  68.       TabIndex        =   6
  69.       Top             =   1200
  70.       Width           =   500
  71.    End
  72.    Begin Label lblTwo 
  73.       BorderStyle     =   1  'Fixed Single
  74.       Height          =   255
  75.       Left            =   3360
  76.       TabIndex        =   5
  77.       Top             =   600
  78.       Width           =   500
  79.    End
  80.    Begin Label lblOne 
  81.       BorderStyle     =   1  'Fixed Single
  82.       Height          =   255
  83.       Left            =   3360
  84.       TabIndex        =   4
  85.       Top             =   120
  86.       Width           =   500
  87.    End
  88. Option Explicit
  89. Dim MyFontSizes(6) As Single
  90. Dim EyeStrings(5) As String
  91. Dim CurrentFont As Integer
  92. Sub cmdCount_Click ()
  93.     MsgBox "There are " & controls.Count & " controls on this form."
  94. End Sub
  95. Sub cmdEnd_Click ()
  96.     Unload form1
  97. End Sub
  98. Sub cmdEnlarge_Click ()
  99.     Dim i As Integer
  100.     CurrentFont = CurrentFont + 1
  101.     For i = 0 To controls.Count - 1
  102.         If TypeOf controls(i) Is Label Then
  103.             controls(i).FontSize = MyFontSizes(CurrentFont)
  104.         End If
  105.     Next i
  106.     PositionEyeBoxes
  107.     cmdShrink.Enabled = True
  108.     If CurrentFont = 6 Then
  109.         cmdEnlarge.Enabled = False
  110.     End If
  111. End Sub
  112. Sub cmdShrink_Click ()
  113.     Dim i As Integer
  114.     CurrentFont = CurrentFont - 1
  115.     For i = 0 To controls.Count - 1
  116.         If TypeOf controls(i) Is Label Then
  117.             controls(i).FontSize = MyFontSizes(CurrentFont)
  118.         End If
  119.     Next i
  120.     PositionEyeBoxes
  121.     If CurrentFont = 1 Then
  122.         cmdShrink.Enabled = False
  123.     End If
  124.     cmdEnlarge.Enabled = True
  125. End Sub
  126. Sub Form_Load ()
  127.     EyeStrings(1) = "E"
  128.     EyeStrings(2) = "F P"
  129.     EyeStrings(3) = "T O Z"
  130.     EyeStrings(4) = "L P E D"
  131.     EyeStrings(5) = "P E C F D"
  132.     lblOne.Caption = EyeStrings(1)
  133.     lblTwo.Caption = EyeStrings(2)
  134.     lblThree.Caption = EyeStrings(3)
  135.     lblFour.Caption = EyeStrings(4)
  136.     lblFive.Caption = EyeStrings(5)
  137.     MyFontSizes(1) = 8.25
  138.     MyFontSizes(2) = 9.75
  139.     MyFontSizes(3) = 12#
  140.     MyFontSizes(4) = 13.5
  141.     MyFontSizes(5) = 18
  142.     MyFontSizes(6) = 24
  143.     CurrentFont = 1
  144.     form1.FontSize = MyFontSizes(CurrentFont)
  145.     lblOne.Top = 200
  146.     PositionEyeBoxes
  147. End Sub
  148. Sub PositionEyeBoxes ()
  149.     Const DELTA = 200
  150.     Const INCREMENT = 100
  151.     Dim ThisLabel As Label
  152.     form1.FontSize = MyFontSizes(CurrentFont)
  153.     form1.Height = 5 * form1.TextHeight("TEST") + 1400
  154.     Set ThisLabel = lblOne
  155.     ThisLabel.Width = form1.TextWidth(EyeStrings(1)) + DELTA
  156.     ThisLabel.Height = form1.TextHeight(EyeStrings(1))
  157.     ThisLabel.Left = (form1.Width - ThisLabel.Width) / 2
  158.     Set ThisLabel = lblTwo
  159.     ThisLabel.Width = form1.TextWidth(EyeStrings(2)) + DELTA
  160.     ThisLabel.Height = form1.TextHeight(EyeStrings(2))
  161.     ThisLabel.Move (form1.Width - ThisLabel.Width) / 2, lblOne.Top + lblOne.Height + INCREMENT
  162.     Set ThisLabel = lblThree
  163.     ThisLabel.Width = form1.TextWidth(EyeStrings(3)) + DELTA
  164.     ThisLabel.Height = form1.TextHeight(EyeStrings(3))
  165.     ThisLabel.Move (form1.Width - ThisLabel.Width) / 2, lblTwo.Top + lblTwo.Height + INCREMENT
  166.     Set ThisLabel = lblFour
  167.     ThisLabel.Width = form1.TextWidth(EyeStrings(4)) + DELTA
  168.     ThisLabel.Height = form1.TextHeight(EyeStrings(4))
  169.     ThisLabel.Move (form1.Width - ThisLabel.Width) / 2, lblThree.Top + lblThree.Height + INCREMENT
  170.     Set ThisLabel = lblFive
  171.     ThisLabel.Width = form1.TextWidth(EyeStrings(5)) + DELTA
  172.     ThisLabel.Height = form1.TextHeight(EyeStrings(5))
  173.     ThisLabel.Move (form1.Width - ThisLabel.Width) / 2, lblFour.Top + lblFour.Height + INCREMENT
  174. End Sub
  175.